<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>编辑用户信息</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
      background-color: #f4f4f4;
    }

    nav {
      background-color: #333;
      padding: 10px 0;
      text-align: center;
    }

    nav ul {
      list-style-type: none;
      margin: 0;
      padding: 0;
      display: flex;
      justify-content: center;
    }

    nav ul li {
      margin: 0 15px;
    }

    nav ul li a {
      color: white;
      text-decoration: none;
      font-size: 18px;
    }

    nav ul li a:hover {
      text-decoration: underline;
    }

    section {
      padding: 20px;
      margin: 20px;
      background-color: white;
      border-radius: 8px;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      max-width: 600px;
      margin: 50px auto;
    }

    h2 {
      color: #333;
    }

    .form-group {
      margin-bottom: 15px;
    }

    .form-group label {
      display: block;
      font-size: 16px;
      color: #333;
    }

    .form-group input {
      width: 100%;
      padding: 8px;
      margin-top: 5px;
      border: 1px solid #ccc;
      border-radius: 5px;
      font-size: 14px;
    }

    .form-group select {
      width: 100%;
      padding: 8px;
      margin-top: 5px;
      border: 1px solid #ccc;
      border-radius: 5px;
      font-size: 14px;
    }

    .btn {
      display: inline-block;
      background-color: #4CAF50;
      color: white;
      padding: 8px 15px;
      text-align: center;
      border-radius: 5px;
      text-decoration: none;
      margin-top: 15px;
    }

    .btn:hover {
      background-color: #45a049;
    }

    .btn-cancel {
      background-color: #f44336;
    }

    .btn-cancel:hover {
      background-color: #e53935;
    }
  </style>
</head>
<body>


<!-- 编辑用户信息表单 -->
<section>
  <h2>编辑用户信息</h2>

  <!-- 用户信息编辑表单 -->
  <form id="editForm" action="save-user.php" method="POST">
    <!-- 用户名 -->
    <div class="form-group">
      <label for="username">用户名</label>
      <input type="text" id="username" name="username" value="张三" required>
    </div>

    <!-- 年龄 -->
    <div class="form-group">
      <label for="age">年龄</label>
      <input type="number" id="age" name="age" value="28" required>
    </div>

    <!-- 性别 -->
    <div class="form-group">
      <label for="gender">性别</label>
      <select id="gender" name="gender">
        <option value="男" selected>男</option>
        <option value="女">女</option>
      </select>
    </div>

    <!-- 紧急联系人 -->
    <h3>紧急联系人</h3>
    <div class="form-group">
      <label for="emergency-name">联系人姓名</label>
      <input type="text" id="emergency-name" name="emergency-name" value="李四" required>
    </div>
    <div class="form-group">
      <label for="emergency-relationship">关系</label>
      <input type="text" id="emergency-relationship" name="emergency-relationship" value="父亲" required>
    </div>
    <div class="form-group">
      <label for="emergency-phone">电话</label>
      <input type="text" id="emergency-phone" name="emergency-phone" value="13876124536" required>
    </div>

    <!-- 提交按钮 -->
    <button type="submit" class="btn">保存修改</button>
    <a href="user-details.html" class="btn btn-cancel">取消</a>
  </form>

  <script>
      document.getElementById('editForm').addEventListener('submit', function(event) {
          event.preventDefault(); // 阻止表单默认提交行为

          // 这里可以添加实际的保存逻辑
          // 例如：发送表单数据到服务器

          // 保存成功后跳转到 user-details.html
          window.location.href = 'user-details.html';
      });
  </script>

</body>
</html>
